package taskit.datastructures;

import taskit.logic.ParserReturnObject;
import taskit.storage.Data;
import taskit.test.Log;

//@author A0098733R
public class CommandDeleteFromArchive extends Command {
	public CommandDeleteFromArchive(Task task, Data data) {
		this.task = task;
		this.data = data;
	}
	
	@Override
	protected void execute(boolean test) throws Exception {
		Log.add("CommandDelete.java: execute()");
		if (task instanceof Floating) {
			data.deleteFromArchive((Floating) task);
			ParserReturnObject.setAction(ParserReturnObject.ACTION_UPDATE_FT);
			if(test) {
				testResult = CMD_ADD_TODO;
			}
		} else {
			throw new Exception("Cannot delete this task.");
		}
	}
	
	@Override
	public Command reverse() {
		return new CommandAddToArchive(task, data);
	}
}
